/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.bean.util.erp;

import com.openbravo.format.Formats;
import com.openbravo.bean.erp.Order;
import com.openbravo.bean.erp.viewbean.FindOrdersInfo;

/**
 *
 * @author Administrator
 */
public class FindOrdersInfoHelper {


    public static String getText(FindOrdersInfo p){

        String sCustomer = (p.customer==null) ? "" : p.customer;

        String sHtml = "<tr><td width=\"30\">"+ "["+ p.orderid +"]" +"</td>" +
                "<td align=\"center\" width=\"100\">"+ p.defineType +"</td>" +
                "<td width=\"150\">"+ Formats.TIMESTAMP.formatValue(p.date) +"</td>" +
                "<td align=\"center\" width=\"100\">"+ sCustomer +"</td>" +
                "<td align=\"center\" width=\"100\">"+ p.location +"</td>" +
                "<td align=\"right\" width=\"100\">"+ Formats.CURRENCY.formatValue(p.totalPrice) +"</td>"+
                "<td width=\"100\">"+ Formats.STRING.formatValue(p.name) +"</td></tr>";

        return sHtml;
    }
    
    public static FindOrdersInfo copyFor(Order o){
    	FindOrdersInfo p=new FindOrdersInfo();
    	p.setId(o.getId());
    	p.setDefineType(o.getDefineType().getName());
    	p.setOrderid(o.getOrderId());
    	p.setOrdertype(o.getOrderType());
    	p.setCustomer(o.getCustomer()==null?null:o.getCustomer().getName());
    	p.setName(o.getUser().getName());
    	p.setDate(o.getDate());
    	p.setCurrentState(o.getCurrentState());
    	p.setLocation(o.getLocationDesc1());
    	p.setLocationRef1(o.getLocationRef1());
    	p.setM_dPriceRate(o.getM_dPriceRate());
    	p.setM_sResponse(o.getReference_User()==null?null:o.getReference_User().getName());
    	p.setMemo(o.getMemo());
    	p.setTotalPrice(o.getTotalPrice());
    	return p;
    }
}
